package com.fc.mall.portal.controller;

import com.fc.mall.base.object.Result;
import com.fc.mall.portal.domain.BargainParam;
import com.fc.mall.portal.service.PmsBargainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by sunny on 2019/9/4.
 */

@RestController
@Api(tags = "PmsBargainController", description = "砍价管理")
@RequestMapping("/bargain")
public class PmsBargainController  {

    @Autowired
    private PmsBargainService bargainService;

    @ApiOperation("获取砍价商品详情")
    @GetMapping("{id}")
    public Result handleGetBargainInfo(@PathVariable Long id)
    {
        return Result.success(bargainService.getBargainInfo(id));
    }

    @GetMapping("list")
    public Result handleGetBargainList(BargainParam bargainParam,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                       @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum)
    {
        return Result.success(bargainService.getList(bargainParam, pageNum, pageSize));
    }


    @PostMapping
    public Result handleCreateBargain(@RequestBody BargainParam bargainParam)
    {
        return Result.success(bargainService);
    }
}
